public class Solution02 {
	public int findBottomLeftValue(TreeNode root){
		//双队列
		//存储当前层的节点
		Queue<TreeNode> curNodes = new LinkedList<>();
		//存储下一层的节点
		Queue<TreeNode> nextNodes = new LinkedList<>();
		boolean isFirst = true;
		int leftVal = 0;

		if(root != null){
			curNodes.offer(root);
		}
		while(!curNodes.isEmpty()){
			TreeNode curNode = curNodes.poll();
			if(isFirst){
				leftVal = curNode.val;
				isFirst = false;
			}
			if(curNode.left != null){
				nextNodes.offer(curNode.left);
			}
			if(curNode.right != null){
				nextNodes.offer(curNode.right);
			}
			if(curNodes.isEmpty()){
				if(nextNodes.isEmpty()){
					break;
				} else {
					curNodes = nextNodes;
					nextNodes = new LinkedList<>();
					isFirst = true;
				}
			}
		}

		return leftVal;
	}
}
